home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.xml.dom;
-
- import java.util.Enumeration;
- import java.util.Hashtable;
- import org.w3c.dom.Attr;
- import org.w3c.dom.CDATASection;
- import org.w3c.dom.Comment;
- import org.w3c.dom.DOMException;
- import org.w3c.dom.DOMImplementation;
- import org.w3c.dom.Document;
- import org.w3c.dom.DocumentFragment;
- import org.w3c.dom.DocumentType;
- import org.w3c.dom.Element;
- import org.w3c.dom.Entity;
- import org.w3c.dom.EntityReference;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import org.w3c.dom.Notation;
- import org.w3c.dom.ProcessingInstruction;
- import org.w3c.dom.Text;
-
- public class DocumentImpl extends NodeImpl implements Document {
- static final long serialVersionUID = 515687835542616694L;
- protected DocumentTypeImpl docType;
- protected ElementImpl docElement;
- protected Hashtable identifiers;
-
- public DocumentImpl() {
- super((DocumentImpl)null, (String)null, (String)null);
- super.ownerDocument = this;
- }
-
- public short getNodeType() {
- return 9;
- }
-
- public String getNodeName() {
- return "#document";
- }
-
- public String getNodeValue() {
- return null;
- }
-
- public Node cloneNode(boolean var1) {
- DocumentImpl var2 = new DocumentImpl();
- if (var1) {
- for(NodeImpl var3 = (NodeImpl)((NodeImpl)this).getFirstChild(); var3 != null; var3 = var3.nextSibling) {
- ((NodeImpl)var2).appendChild(var2.importNode(var3, true));
- }
- }
-
- return var2;
- }
-
- public Node insertBefore(Node var1, Node var2) throws DOMException {
- short var3 = var1.getNodeType();
- if ((var3 != 1 || this.docElement == null) && (var3 != 10 || this.docType == null)) {
- super.insertBefore(var1, var2);
- if (var3 == 1) {
- this.docElement = (ElementImpl)var1;
- } else if (var3 == 10) {
- this.docType = (DocumentTypeImpl)var1;
- }
-
- return var1;
- } else {
- throw new DOMExceptionImpl((short)3, (String)null);
- }
- }
-
- public Node removeChild(Node var1) throws DOMException {
- super.removeChild(var1);
- short var2 = var1.getNodeType();
- if (var2 == 1) {
- this.docElement = null;
- } else if (var2 == 10) {
- this.docType = null;
- }
-
- return var1;
- }
-
- public void setNodeValue(String var1) throws DOMException {
- throw new DOMExceptionImpl((short)7, (String)null);
- }
-
- public Attr createAttribute(String var1) throws DOMException {
- if (!isXMLName(var1)) {
- throw new DOMExceptionImpl((short)5, (String)null);
- } else {
- return new AttrImpl(this, var1);
- }
- }
-
- public CDATASection createCDATASection(String var1) throws DOMException {
- return new CDATASectionImpl(this, var1);
- }
-
- public Comment createComment(String var1) {
- return new CommentImpl(this, var1);
- }
-
- public DocumentFragment createDocumentFragment() {
- return new DocumentFragmentImpl(this);
- }
-
- public Element createElement(String var1) throws DOMException {
- if (!isXMLName(var1)) {
- throw new DOMExceptionImpl((short)5, (String)null);
- } else {
- return new ElementImpl(this, var1);
- }
- }
-
- public EntityReference createEntityReference(String var1) throws DOMException {
- if (!isXMLName(var1)) {
- throw new DOMExceptionImpl((short)5, (String)null);
- } else {
- return new EntityReferenceImpl(this, var1);
- }
- }
-
- public ProcessingInstruction createProcessingInstruction(String var1, String var2) throws DOMException {
- if (!isXMLName(var1)) {
- throw new DOMExceptionImpl((short)5, (String)null);
- } else {
- return new ProcessingInstructionImpl(this, var1, var2);
- }
- }
-
- public Text createTextNode(String var1) {
- return new TextImpl(this, var1);
- }
-
- public DocumentType getDoctype() {
- if (super.syncChildren) {
- ((NodeImpl)this).synchronizeChildren();
- }
-
- return this.docType;
- }
-
- public Element getDocumentElement() {
- if (super.syncChildren) {
- ((NodeImpl)this).synchronizeChildren();
- }
-
- return this.docElement;
- }
-
- public NodeList getElementsByTagName(String var1) {
- return new DeepNodeListImpl(this, var1);
- }
-
- public DOMImplementation getImplementation() {
- return DOMImplementationImpl.singleton;
- }
-
- public DocumentType createDocumentType(String var1) throws DOMException {
- if (!isXMLName(var1)) {
- throw new DOMExceptionImpl((short)5, (String)null);
- } else {
- return new DocumentTypeImpl(this, var1);
- }
- }
-
- public Entity createEntity(String var1) throws DOMException {
- return new EntityImpl(this, var1);
- }
-
- public Notation createNotation(String var1) throws DOMException {
- return new NotationImpl(this, var1);
- }
-
- public ElementDefinitionImpl createElementDefinition(String var1) throws DOMException {
- return new ElementDefinitionImpl(this, var1);
- }
-
- public Node importNode(Node var1, boolean var2) throws DOMException {
- Object var3 = null;
- short var4 = var1.getNodeType();
- switch (var4) {
- case 1:
- Element var12 = this.createElement(var1.getNodeName());
- NamedNodeMap var17 = var1.getAttributes();
- if (var17 != null) {
- for(int var19 = 0; var19 < var17.getLength(); ++var19) {
- var12.setAttributeNode((AttrImpl)this.importNode(var17.item(var19), true));
- }
- }
-
- var3 = (NodeImpl)var12;
- break;
- case 2:
- var3 = (NodeImpl)this.createAttribute(var1.getNodeName());
- break;
- case 3:
- var3 = (NodeImpl)this.createTextNode(var1.getNodeValue());
- break;
- case 4:
- var3 = (NodeImpl)this.createCDATASection(var1.getNodeValue());
- break;
- case 5:
- var3 = (NodeImpl)this.createEntityReference(var1.getNodeName());
- var2 = false;
- break;
- case 6:
- Entity var11 = (Entity)var1;
- EntityImpl var16 = (EntityImpl)this.createEntity(var1.getNodeName());
- var16.setPublicId(var11.getPublicId());
- var16.setSystemId(var11.getSystemId());
- var16.setNotationName(var11.getNotationName());
- var3 = var16;
- break;
- case 7:
- var3 = (ProcessingInstructionImpl)this.createProcessingInstruction(var1.getNodeName(), var1.getNodeValue());
- break;
- case 8:
- var3 = (NodeImpl)this.createComment(var1.getNodeValue());
- break;
- case 9:
- default:
- throw new DOMExceptionImpl((short)3, (String)null);
- case 10:
- DocumentTypeImpl var10 = (DocumentTypeImpl)this.createDocumentType(var1.getNodeName());
- NamedNodeMap var14 = ((DocumentType)var1).getEntities();
- NamedNodeMap var7 = var10.getEntities();
- if (var14 != null) {
- for(int var8 = 0; var8 < var14.getLength(); ++var8) {
- var7.setNamedItem((EntityImpl)this.importNode(var14.item(var8), true));
- }
- }
-
- var14 = ((DocumentType)var1).getNotations();
- var7 = var10.getNotations();
- if (var14 != null) {
- for(int var20 = 0; var20 < var14.getLength(); ++var20) {
- var7.setNamedItem((NotationImpl)this.importNode(var14.item(var20), true));
- }
- }
-
- var3 = var10;
- break;
- case 11:
- var3 = (NodeImpl)this.createDocumentFragment();
- break;
- case 12:
- Notation var5 = (Notation)var1;
- NotationImpl var6 = (NotationImpl)this.createNotation(var1.getNodeName());
- var6.setPublicId(var5.getPublicId());
- var6.setSystemId(var5.getSystemId());
- var3 = var6;
- }
-
- if (var2) {
- for(Node var13 = var1.getFirstChild(); var13 != null; var13 = var13.getNextSibling()) {
- ((NodeImpl)var3).appendChild(this.importNode(var13, true));
- }
- }
-
- return (Node)var3;
- }
-
- public void putIdentifier(String var1, Element var2) {
- if (var2 == null) {
- this.removeIdentifier(var1);
- }
-
- if (super.syncData) {
- ((NodeImpl)this).synchronizeData();
- }
-
- if (this.identifiers == null) {
- this.identifiers = new Hashtable();
- }
-
- this.identifiers.put(var1, var2);
- }
-
- public Element getIdentifier(String var1) {
- if (super.syncData) {
- ((NodeImpl)this).synchronizeData();
- }
-
- return this.identifiers == null ? null : (Element)this.identifiers.get(var1);
- }
-
- public void removeIdentifier(String var1) {
- if (super.syncData) {
- ((NodeImpl)this).synchronizeData();
- }
-
- if (this.identifiers != null) {
- this.identifiers.remove(var1);
- }
- }
-
- public Enumeration getIdentifiers() {
- if (super.syncData) {
- ((NodeImpl)this).synchronizeData();
- }
-
- if (this.identifiers == null) {
- this.identifiers = new Hashtable();
- }
-
- return this.identifiers.keys();
- }
-
- public static boolean isXMLName(String var0) {
- char[] var1 = new char[var0.length()];
- var0.getChars(0, var0.length(), var1, 0);
- if (!Character.isLetter(var1[0]) && "_:".indexOf(var1[0]) == -1) {
- return false;
- } else {
- for(int var2 = 1; var2 < var0.length(); ++var2) {
- char var3 = var1[var2];
- int var4 = Character.getType(var3);
- if (!Character.isLetterOrDigit(var3) && ".-_:".indexOf(var3) == -1 && (var4 < 6 || var4 > 8 || var3 >= 1757 && var3 <= 1758 || var3 >= 8413 && var3 <= 8416 || var3 >= 12443) && (var4 != 4 || var3 >= 720 && var3 <= 1369 || var3 >= 1765 && var3 <= 1766 || var3 >= 12443 && var3 <= 12444) && var3 != 183 && var3 != 903) {
- return false;
- }
- }
-
- return true;
- }
- }
- }
-